package com.sharemarking.system.autoconfigure;

import com.qcloud.cos.COSClient;
import com.qcloud.cos.ClientConfig;
import com.qcloud.cos.auth.BasicCOSCredentials;
import com.qcloud.cos.auth.COSCredentials;
import com.qcloud.cos.region.Region;

import com.sharemarking.system.properties.CosProperties;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import com.aliyun.oss.OSSClient;
import com.sharemarking.system.controller.MenuController;
import com.sharemarking.system.mapper.UserMapper;
//import com.sharemarking.system.properties.AliOSSProperties;
//import com.sharemarking.system.properties.AliSecretProperties;
import com.sharemarking.system.service.DictService;
import com.sharemarking.system.service.impl.MenuServiceImpl;

@Configuration
//@ComponentScan(basePackageClasses={MenuController.class,MenuServiceImpl.class,DictService.class})
//@EnableConfigurationProperties({AliOSSProperties.class,AliSecretProperties.class,CosProperties.class})
//@MapperScan(basePackageClasses=UserMapper.class)
@ComponentScan(basePackageClasses={MenuController.class,MenuServiceImpl.class,DictService.class})
@EnableConfigurationProperties({CosProperties.class})
@MapperScan(basePackageClasses=UserMapper.class)
public class SystemAutoConfigure {
//	@Autowired
//	private AliOSSProperties prop;
//
//	@Autowired
//	private AliSecretProperties sProp;

	@Autowired
	private CosProperties cop;

//	@Bean
//	public OSSClient ossClient(){
//		return new OSSClient(prop.getEndpoint(), sProp.getAccessKeyId(), sProp.getAccessKeySecret());
//	}
//



	@Bean
	public COSClient cosClient(){
		COSCredentials cred = new BasicCOSCredentials(cop.getSecretid(), cop.getSecretkey());
		Region region = new Region(cop.getRegion());
		ClientConfig clientConfig = new ClientConfig(region);
		COSClient cosClient = new COSClient(cred, clientConfig);
		return cosClient;
	}
}
